using AppToolKit.Core;
using System;
using System.Data;
namespace AppToolKit.Data
{
	public class DbTypeMapping : TypeMappingBase<DbType, TypeCode>
	{
		public override DbType From(object o)
		{
			TypeCode typeCode = Convert.GetTypeCode(o);
			TypeCode typeCode2 = typeCode;
			DbType result;
			if (typeCode2 != TypeCode.Char)
			{
				switch (typeCode2)
				{
				case TypeCode.Int32:
					result = DbType.Int32;
					return result;

				case TypeCode.Single:
					result = DbType.Single;
					return result;

				case TypeCode.Double:
					result = DbType.Double;
					return result;

				case TypeCode.Decimal:
					result = DbType.Decimal;
					return result;

				case TypeCode.DateTime:
					result = DbType.DateTime;
					return result;

				case TypeCode.String:
					result = DbType.AnsiString;
					return result;
				}
				throw new NotSupportedException(string.Format("type:{0},object:{1}", typeCode, o));
			}
			result = DbType.AnsiString;
			return result;
		}
	}
}
